from typing import Dict, Any, List
from .base_service_handler import BaseServiceHandler, ServiceHandlerFactory

class MailServiceHandler(BaseServiceHandler):
    """邮件服务信息处理器"""
    
    def get_service_details(self, service_info: Dict[str, Any]) -> List[str]:
        """获取邮件服务的详细信息"""
        details = []
        
        # 基本信息
        if service_info.get('product'):
            details.append(f"产品: {self._safe_str(service_info['product'])}")
        if service_info.get('version'):
            details.append(f"版本: {self._safe_str(service_info['version'])}")
        if service_info.get('banner'):
            details.append(f"Banner: {self._safe_str(service_info['banner'])}")
            
        # 邮件服务特定信息
        if service_info.get('mail_version'):
            details.append(f"邮件服务版本: {self._safe_str(service_info['mail_version'])}")
        if service_info.get('auth_methods'):
            details.append(f"支持的认证方式: {', '.join(map(self._safe_str, service_info['auth_methods']))}")
        if service_info.get('starttls_supported') is not None:
            details.append(f"STARTTLS支持: {'是' if service_info['starttls_supported'] else '否'}")
        if service_info.get('ssl_tls_supported') is not None:
            details.append(f"SSL/TLS支持: {'是' if service_info['ssl_tls_supported'] else '否'}")
            
        return details

# 注册邮件服务处理器
for mail_type in ['smtp', 'pop3', 'imap']:
    ServiceHandlerFactory.register_handler(mail_type, MailServiceHandler) 